package DomainLayer;

import Annotations.AttributeNameAnnotation;
import Annotations.ValueObjectNameAnnotation;

@ValueObjectNameAnnotation(Name = "Profit")
public class ProfitValueObject extends AbstractValueObject {
	@AttributeNameAnnotation(Name = "ProfitInRussia", isAggregator = false)
	private final double profitInRussia;
	@AttributeNameAnnotation(Name = "ProfitInUSA", isAggregator = false)
	private final double profitInUSA;
	@AttributeNameAnnotation(Name = "ProfitInEurope", isAggregator = false)
	private final double profitInEurope;
	@AttributeNameAnnotation(Name = "ProfitInOtherCountries", isAggregator = false)
	private final double profitInOtherCountries;
	@AttributeNameAnnotation(Name = "ProfitFromTV", isAggregator = false)
	private final double profitFromTV;
	@AttributeNameAnnotation(Name = "ProfitFromDVD", isAggregator = false)
	private final double profitFromDVD;

	public ProfitValueObject() {
		super();
		profitInRussia = 0;
		profitInUSA = 0;
		profitInEurope = 0;
		profitInOtherCountries = 0;
		profitFromTV = 0;
		profitFromDVD = 0;
	}

	// Use this cotr for create or change value object. Instance of this class
	// MUST be immutable.
	/**
	 * @param currentProfitValueObject
	 * @param profits
	 *            should be in sequence: profitInRussia, profitInUSA,
	 *            profitInEurope, profitInOtherCountries, profitFromDVD,
	 *            profitFromTV
	 */
	public ProfitValueObject(ProfitValueObject currentProfit, Object... profits) {
		super(currentProfit, profits[0]);
		profitInRussia = (profits[1] != null ? (Double) profits[1]
				: currentProfit.profitInRussia);
		profitInUSA = (profits[2] != null ? (Double) profits[2]
				: currentProfit.profitInUSA);
		profitInEurope = (profits[3] != null ? (Double) profits[3]
				: currentProfit.profitInEurope);
		profitInOtherCountries = (profits[4] != null ? (Double) profits[4]
				: currentProfit.profitInOtherCountries);
		profitFromTV = (profits[5] != null ? (Double) profits[5]
				: currentProfit.profitFromTV);
		profitFromDVD = (profits[6] != null ? (Double) profits[6]
				: currentProfit.profitFromDVD);
	}

	public double getTotalProfit() {
		return profitInRussia + profitInUSA + profitInEurope
				+ profitInOtherCountries + profitFromDVD + profitFromTV;
	}

	public double getProfitInRussia() {
		return profitInRussia;
	}

	public double getProfitInUSA() {
		return profitInUSA;
	}

	public double getProfitInEurope() {
		return profitInEurope;
	}

	public double getProfitInOtherCountries() {
		return profitInOtherCountries;
	}

	public double getProfitFromTV() {
		return profitFromTV;
	}

	public double getProfitFromDVD() {
		return profitFromDVD;
	}
}